<% include ../inc/head.ejs%>
<div class="container">

    <div class="col-md-8">
        <div>
            <ol class="breadcrumb">
                <li><a href="/">首页</a></li>
                <li><a href="/articles/lst/<%=data.cat_id%>"><%=data.cat_name%></a></li>
                <li class="active"><%=data.title.substr(0,20)%></li>
            </ol>

        </div>
        <div class="article-list">
            <h4><a href="#"><%=data.title.substr(0,20)%></a>
                <% if(session_user!='' && data.user_id._id==session_user._id) {%>
                <a href="/articles/edit/<%=data._id%>/<%=data.pic?data.pic:0%>/<%=data.user_id._id%>" class="btn btn-sm btn-warning">编辑</a> <a href="/articles/del/<%=data._id%>/<%=data.cat_id%>/<%=data.pic?data.pic:0%>/<%=data.user_id._id%>" class="btn btn-sm btn-danger">删除</a>
                <%}%>
            </h4>
            <h5><i class="glyphicon glyphicon-dashboard"></i> <span><%=FormatDate(data.addtime.toLocaleString())%></span>  <i class="glyphicon glyphicon-user"></i> <span><%=data.user_id.username%></span>  <i class="glyphicon glyphicon-list"></i> <span><%=data.cat_name%></span></h5>
                <div >
                    <% if(data.pic){ %>
                    <img src="/<%=data.pic%>" alt="<%=data.title%>" class="img-responsive">
                    <%}%>
                </div>
                    <div><%-data.content%></div>
        </div>
        <div class="clearfix"></div>
        <div class="panel panel-default">
            <div class="panel-heading">
                评论列表
            </div>
            <div class="panel-body"  style="height:300px;overflow-y: scroll">
                <ul class="media-list">
                    <%
                    data.comments.forEach(function(comment){
                    %>
                    <li class="media">
                        <div class="media-left">
                            <a href="#">
                                <img class="media-object" src="<%=comment.user.avatar%>" alt="">
                            </a>
                        </div>
                        <div class="media-body">
                            <p class="media-left"><%- comment.content%></p>
                        </div>
                        <div class="media-bottom">
                            <%=comment.user.username%> <%=comment.addtime.toLocaleString()%>
                        </div>
                    </li>
                    <%
                    });
                    %>
                </ul>
            </div>

        </div>

        <div class="panel panel-default">
            <form action="/articles/comment" method="post">
                <input type="hidden" value="<%=data._id%>" name="_id"/>
                <div class="panel-body">
                    <textarea class="form-control"   id="" cols="30" rows="10" id="content" name="content" placeholder="请输入评论" ></textarea>
                </div>
                <div class="panel-footer">
                    <button type="submit" class="btn btn-default">提交</button>
                </div>
            </form>
        </div>
    </div>
    <div class="col-md-4">
        <% include ../inc/right.ejs%>
    </div>
</div>
<% include ../inc/footer.ejs%>